package com.ruoyi.market.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum InfoTypeEnum {

    CRM("CRM", "CRM"),
    API("API", "API"),
    APIB("APIB", "API半流程"),
    APIS("APIS", "API全流程"),
    ;

    String value;
    String name;

    InfoTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    public static List<Map<String, Object>> getMapList(){
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (InfoTypeEnum item : values()) {
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("name", item.getName());
            itemMap.put("value", item.getValue());
            resultList.add(itemMap);
        }
        return resultList;
    }
    public static String getNameByValue(String value){
        for (InfoTypeEnum item: values()){
            if (StrUtil.equals(value, item.getValue())){
                return item.getName();
            }
        }
        return value;
    }
}
